﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Business.Enums;
using mozhi.smarterp.Business.Sales.Deliveries;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.Business.Controllers.Sales
{
    [RemoteService]
    [Route("api/v1/sales/deliveries")]
    public class SaleDeliveryController : BusinessController
    {
        private ISaleDeliveryAppService _appService;

        public SaleDeliveryController(ISaleDeliveryAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<SaleDeliveryDto> GetAsync(Guid id)
        {
            return await _appService.GetAsync(id);
        }

        [HttpGet]
        public async Task<PagedResultDto<SaleDeliveryDto>> GetAsync(SaleDeliveryPagedResultRequestDto filter)
        {
            return await _appService.GetListAsync(filter);
        }

        [HttpPost]
        public async Task<SaleDeliveryDto> CreateAsync(SaleDeliveryCreateDto input)
        {
            return await _appService.CreateAsync(input);
        }

        [HttpPut]
        public async Task<SaleDeliveryDto> UpdateAsync(SaleDeliveryUpdateDto input)
        {
            return await _appService.UpdateAsync(input);
        }

        [HttpPut]
        [Route("{id}/status/{status}")]
        public async Task<SaleDeliveryDto> UpdateStatusAsync(Guid id, DocumentStatusType status)
        {
            return await _appService.UpdateStatusAsync(id, status);
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }

    }
}
